package com.hotel.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hotel.daos.RevenueMapper;
import com.hotel.entitys.Revenue;
import com.hotel.services.RevenueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
@Service
@Transactional
public class RevenueServiceImpl implements RevenueService {
    @Autowired
    private RevenueMapper revenueMapper;

    @Override
    public PageInfo<Revenue> selectAllRevenue(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Revenue> revenueList = revenueMapper.selectAllRevenue();
        PageInfo<Revenue> pageInfo = new PageInfo<>(revenueList);
        return pageInfo;
    }

    @Override
    public PageInfo<Revenue> selectRevenueByDate(String revenue_date) {
        PageHelper.startPage(1,1);
        List<Revenue> revenueList = revenueMapper.selectRevenueByDate(revenue_date);
        PageInfo<Revenue> pageInfo = new PageInfo<>(revenueList);
        return pageInfo;
    }

    @Override
    public Integer addRevenue(Double revenue_sum, Date revenue_date) {
        return revenueMapper.addRevenue(revenue_sum,revenue_date);
    }
}
